﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Assignment4
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length == 2)
            {
                List<Example> train = ReadFile.Read(args[0]);
                List<Example> test = ReadFile.Read(args[1]);
                DecisionNode root = new DecisionNode(0);
                List<string> attributeTypes=Example.AttributeCollection.Keys.ToList();
                ID3Tree.makeTree(train, attributeTypes, root);
                Console.WriteLine("======Start print tree=======");
                ID3Tree.printTree(root);
                Console.WriteLine("======End print tree=========\n");

                List<Example> incorrectSet = new List<Example>();
                foreach (Example example in test)
                {
                    if (!ID3Tree.testNode(example, root))
                    {
                        incorrectSet.Add(example);
                    }
                }

                Console.WriteLine("======Statistics========");
                Console.WriteLine("# incorrect: {0}\n% incorrect: {1}", incorrectSet.Count, incorrectSet.Count * 100.0f / test.Count);
                Console.WriteLine("====Incorrect tests======");
                foreach (Example example in incorrectSet)
                {
                    Console.WriteLine(example.Name);
                }

                Console.ReadLine();

            }
            else
            {
                Console.WriteLine("Please put the correct argument");
                Console.ReadLine();
            }
        }


    }
}
